package com.itheima.day08.myTreeSet.test1;

import java.util.Iterator;
import java.util.TreeSet;

public class test2 {
    public static void main(String[] args) {
        TreeSet<Student> treeSet = new TreeSet<>();
        Student s1 = new Student("美美",21);
        Student s2 = new Student("丽丽",22);
        Student s3 = new Student("渣渣",99);
        treeSet.add(s1);
        treeSet.add(s2);
        treeSet.add(s3);
        Iterator<Student> it = treeSet.iterator();
        while(it.hasNext()){
            System.out.print(it.next().toString() + " "); // ClassCastException 未给TreeSet集合指定排序规则
        }
    }
}
